package com.sparsearr.datastructures.itheima.yanzhengma;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Random;

/**
 * @Author: ZhaoTR
 * @Date: Created in 2025/4/19 16:22
 * @Description: 验证码
 * @Version: 1.0
 */

public class Nums {
    private static final Logger logger = LogManager.getLogger(Nums.class);

    public static void main(String[] args) {
        char[] chs = new char[52];
        for (int i = 0; i < chs.length; i++) {
//            chs[i] = 'a';
            if (i < 26) {
                chs[i] = (char) (97 + i);
            } else {
                chs[i] = (char) (65 + i - 26);
            }
        }

        String result = "";
        Random random = new Random();
        for (int i = 0; i < 4; i++) {
            int randomIndex = random.nextInt(chs.length);
            logger.info("随机下标为：{}", chs[randomIndex]);
            result = result + chs[randomIndex];
        }

        int num = random.nextInt(10);

        result += num;

        logger.info("验证码为：{}", result);


//        for (int i = 0; i < chs.length; i++) {
//            System.out.print(chs[i] + " ");
////            System.out.print(chs[i] + ' ');
//        }
    }
}
